<link href="<?php echo URL::base() ?>media/vendor/css/ui-lightness/jquery-ui-1.10.4.custom.css" rel="stylesheet">
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-1.10.2.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-1.10.4.custom.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.datepicker-zh-TW.js"></script>
<style>
.myborder , .myborder th , .myborder td{border: 1px solid #ffffff;}
.control-label{ display:inline-block; width:80px; text-align:right; margin-right:10px;}
.table1 thead tr td,.table1 tbody tr td{ text-align:center;}
</style>
<script type="text/javascript">
$(document).ready(function(){
	$('.table1 > tbody > tr:odd').css("background-color","#f5f5f5");
})
</script>
<form method='get' action='<? echo URL::site() ?>stockcost/selectstock'>
 <div class="control-group">
    <label class="control-label" >时间选择:</label>
    <input type='text' style="width:164px;" name='date_from' class=" datepicker" id="date_from" > ~ <input type='text' name='date_to' style="width:164px;" id='date_to' class=" datepicker" >
</div>
<div class="control-group">
    <label class="control-label" >SKU:</label>
    <input type='text' style="width:164px;" name='sku' id='sku'>
</div>
<div class="control-group">
    <label class="control-label"></label>
   <input type='submit' class="btn btn-info" value='查询'>
   <input type='button' class="btn btn-success" value='全部下载' onclick="down_all()">
 </div>


</form>
<div style ='padding-top:5%'>
<table class="table table1 table-bordered myborder">
<thead>
<tr style="background-color:#4EA392; font-weight:bold; color:#ffffff;">
<td  rowspan=2>sku</td>
<td  rowspan=2>中文名称</td>
<td  rowspan=2>规格</td>
<td  rowspan=2>储位</td>
<td colspan="2">期初</td>
<td colspan="2">本期入</td>
<td colspan="2">本期出</td>
<td colspan="2">期末结存</td>
</tr>
<tr style="background-color:#4EA392; font-weight:bold; color:#ffffff;">
<td>数量</td>
<td>成本</td>
<td>数量</td>
<td>成本</td>
<td>数量</td>
<td>成本</td>
<td>数量</td>
<td>成本</td>
</tr>
</thead>
<tbody>
<?php if(isset($stockcost)){
			foreach($stockcost as $cost){?>
<tr>
<td><?php echo isset($cost['sku'])?$cost['sku']:'' ?></td>
<td><?php echo isset($sku_arr[$cost['sku']]['sku_name'])?$sku_arr[$cost['sku']]['sku_name']:'' ?></td>
<td><?php echo isset($sku_arr[$cost['sku']]['sku_standard'])?$sku_arr[$cost['sku']]['sku_standard']:'' ?></td>
<td><?php echo isset($sku_arr[$cost['sku']]['storage_position'])?$sku_arr[$cost['sku']]['storage_position']:'' ?></td>
<td><?php echo $cost['open_num']?></td>
<td><?php echo $cost['open_cost']?></td>
<td><?php echo $cost['in_num']?></td>
<td><?php echo $cost['in_cost']?></td>
<td><?php echo $cost['out_num']?></td>
<td><?php echo $cost['out_cost']?></td>
<td><?php echo $cost['num']?></td>
<td><?php echo $cost['cost']?></td>
</tr>
<?php }?>
<!--<tr>-->
<!--<td colspan=4>本页汇总</td>-->
<!--<td>--><?php //echo isset($sortcost['opening_num'])?$sortcost['opening_num']:0 ?><!--</td>-->
<!--<td>--><?php //echo isset($sortcost['opening_cost'])?$sortcost['opening_cost']:0 ?><!--</td>-->
<!--<td>--><?php //echo isset($sortcost['wo_num'])?$sortcost['wo_num']:0 ?><!--</td>-->
<!--<td>--><?php //echo isset($sortcost['wo_cost'])?$sortcost['wo_cost']:0 ?><!--</td>-->
<!--<td>--><?php //echo isset($sortcost['do_num'])?$sortcost['do_num']:0 ?><!--</td>-->
<!--<td>--><?php //echo isset($sortcost['do_cost'])?$sortcost['do_cost']:0 ?><!--</td>-->
<!--<td>--><?php //echo isset($sortcost['ending_num'])?$sortcost['ending_num']:0 ?><!--</td>-->
<!--<td>--><?php //echo isset($sortcost['ending_cost'])?$sortcost['ending_cost']:0 ?><!--</td>-->
<!--</tr>-->
<?php }?>
<?php if(!empty($sum_num_cost)):?>
<tr>
<td colspan=4>查询时间段里的的所有库存成本</td>
<td><?php echo isset($sum_num_cost['opening_num'])?$sum_num_cost['opening_num']:0 ?></td>
<td><?php echo isset($sum_num_cost['opening_cost'])?$sum_num_cost['opening_cost']:0 ?></td>
<td><?php echo isset($sum_num_cost['wo_num'])?$sum_num_cost['wo_num']:0 ?></td>
<td><?php echo isset($sum_num_cost['wo_cost'])?$sum_num_cost['wo_cost']:0 ?></td>
<td><?php echo isset($sum_num_cost['do_num'])?$sum_num_cost['do_num']:0 ?></td>
<td><?php echo isset($sum_num_cost['do_cost'])?$sum_num_cost['do_cost']:0 ?></td>
<td><?php echo isset($sum_num_cost['ending_num'])?$sum_num_cost['ending_num']:0 ?></td>
<td><?php echo isset($sum_num_cost['ending_cost'])?$sum_num_cost['ending_cost']:0 ?></td>
</tr>
<?php endif;?>
</tbody>
</table>
<?php if(isset($pagination))echo $pagination;?>
</div>

<script type="text/javascript">
$(function(){

$("#date_from").val('<?php echo isset($date_from)?$date_from:''; ?>');
$("#date_to").val('<?php echo isset($date_to)?$date_to:''; ?>');
$("#sku").val('<?php echo isset($sku)?$sku:''; ?>');
							$.datepicker.setDefaults({ dateFormat: 'yy-mm-dd' });
							$("#date_from").datepicker({  
							    onSelect:function(dateText,inst){  
							       $("#date_to").datepicker("option","minDate",dateText);  
							    }  
							});  
							$("#date_to").datepicker({  
							    onSelect:function(dateText,inst){  
							        $("#date_from").datepicker("option","maxDate",dateText);  
							    }  
							});  
});

function down_all()
{
	var date_from = $('#date_from').val();
	var date_to = $('#date_to').val();
	var sku = $('#sku').val();
 window.location.href="<?php echo URL::site(); ?>stockcost/down?date_from="+date_from+"&date_to="+date_to+"&sku="+sku;

}


</script>


